﻿namespace Jsl.FxCop
{
    using System.Collections.ObjectModel;
    using Microsoft.FxCop.Sdk;

    public class UniqueTypeCollection<TTypeNode> : Collection<TTypeNode>
        where TTypeNode : TypeNode
    {
        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="UniqueTypeCollection&lt;TTypeNode&gt;"/> class.
        /// </summary>
        public UniqueTypeCollection()
        {
        }
        #endregion Constructors

        #region Protected Methods
        /// <summary>
        /// Inserts the item.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="item">The item.</param>
        protected override void InsertItem(int index, TTypeNode item)
        {
            if (!this.Items.Contains(item))
            {
                this.Items.Add(item);
            }
        }
        #endregion Protected Methods
    }
}